<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查询字符串请求</title>
</head>
<body>
    <form id='form'>
        <input id="ipt" type="text">
        <button id="btn">提交get请求获取数据</button>
    </form>
    <script>
         const oform=document.getElementById('form')
         const oipt=document.getElementById('ipt')
         const obtn=document.getElementById('btn')
        oform.onsubmit=function(){
            const xhr=new XMLHttpRequest()
            const userID=oipt.value
            xhr.open('GET',`/user?userID=${userID}&_=${Date.now()}`,true)
            xhr.send()
            xhr.onreadystatechange=function(){
                if(xhr.readyState===4&&xhr.status>=200&&xhr.status<=299){
                    console.log(JSON.parse(xhr.responseText));
                }
            }
            return false
        }
    </script>
</body>
</html>